/**
* Author: CZ cz.theng@gmail.com
 */

package main

import (
	"./pkg"
	"fmt"
)

//Baser is a interface
type Baser interface {
	Info() string
}

//Base is Base class
type Base struct {
	i   int
	str string
}

//Info get class's info of i and str
func (b Base) Info() string {
	info := fmt.Sprintf("str[%s] i[%d]", b.str, b.i)
	return info
}

// SubClass is a subclass of base
type SubClass struct {
	Base
	j int
}

// AnOtherSubClass subclass of base
type AnOtherSubClass struct {
	Base
	k int
}

//Info is a implementation of Baser
func (a AnOtherSubClass) Info() string {
	return "another subclass"
}

func getInfo(b Baser) {
	fmt.Println("b is ", b.Info())
}

func main() {
	fmt.Println(pkg.Pkg())

	sc := &SubClass{
		Base{
			i:   2,
			str: "subclass",
		},
		3,
	}
	asc := &AnOtherSubClass{
		Base{
			i:   5,
			str: "another subclass",
		},
		6,
	}
	getInfo(sc)
	getInfo(asc)
}
